
package laya.semi.process;

import java.util.*;

public class Transition
{
	private State m_oFromState = null;
	private State m_oToState = null;
	
	private List m_oInhibits = null;
	
	public Transition(State oFromState)
	{
		m_oFromState = oFromState;
	}
	
	public State getFromState()
	{
		return m_oFromState;
	}
	
	public void setToState(State oToState)
	{
		m_oToState = oToState;
	}
	
	public State getToState()
	{
		return m_oToState;
	}
	
	public void addCondition(Condition oCond)
		throws ProcessCompileException
	{
		switch(m_oFromState.getStateType())
		{
			case State.END:
				throw new ProcessCompileException(1104, new Object[] {oCond, m_oFromState});
			case State.START:
			case State.FORK:
			case State.JOIN:
				throw new ProcessCompileException(1118, new Object[] {oCond, m_oFromState});
		}
		
		if (State.END == m_oToState.getStateType())
		{
			throw new ProcessCompileException(1119, new Object[] {oCond, m_oFromState});
		}
		
		if (null == m_oInhibits)
		{
			m_oInhibits = new Vector();
		}
		
		m_oInhibits.add(oCond);
	}

	public List getInhibits()
	{
		return m_oInhibits;
	}
}
